<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/5/23
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="/layui/jquery-3.6.0.min.js"></script>
    <script>
        $(function () {
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage
                    , layer = layui.layer;
                //分组件
                laypage.render({
                    elem: 'pagesData'
                    , count: ${pageInfo.total}
                    , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    , limit: ${pageInfo.pageSize}
                    , limits: [5, 10, 15]
                    , curr:${pageInfo.pageNum}
                    , jump: function (obj,first) {
                        //首次不执行
                        if(!first){
                            if (obj.curr !=${pageInfo.pageNum}) {
                                location.href = "/users/findAll?page=" + obj.curr + "&limit=" + obj.limit+"&productName="+$("#key").val()
                            }else if(obj.limit!=${pageInfo.pageSize}){
                                location.href = "/users/findAll?page=1&limit=" + obj.limit+"&productName="+$("#key").val()
                            }
                        }
                    }


                });


            });




        })

        function delids(id, name) {
            //询问框
            layer.confirm('确定删除用户[' + name + ']？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                location.href = "/users/delete?id=" + id;
                // return true;
                //layer.msg('的确很重要', {icon: 1});
            }, function () {
                //  return false;
            });
        }
    </script>


</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>用户列表</legend>
</fieldset>
<div class="layui-bg-gray" style="padding: 0px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">

                    <div class="layui-btn-group">
                        <a href="/users/add" class="layui-btn layui-btn-normal layui-btn-sm">
                            <i class="layui-icon ayui-icon-add-circle"></i>用户添加
                        </a>

                    </div>
                    &nbsp; &nbsp; &nbsp; &nbsp;

                </div>


                <!--数据表-->
                <table id="dataList列" class="layui-table">
                    <thead>
                    <tr>

                        <th>ID</th>
                        <th>账号</th>
                        <th>邮箱</th>
                        <th>手机号</th>
                        <th>角色</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${pageInfo.list}" var="users">
                        <tr>

                            <td>${users.id}</td>
                            <td>${users.username}</td>
                            <td>${users.email}</td>
                            <td>${users.phoneNum}</td>
                            <td>${users.r.roleName}</td>
                            <td>
                                <c:if test="${users.status==1}">
                                    开启
                                </c:if>
                                <c:if test="${users.status==0}">
                                    关闭
                                </c:if>

                            </td>
                            <td class="text-center">

                                    <%--修改--%>
                                <a title="修改" class="layui-btn layui-btn-warm layui-btn-xs"
                                   href="${pageContext.request.contextPath}/users/edit?id=${users.id}"><i
                                        class="layui-icon layui-icon-set-fill"></i> <span
                                        class="glyphicon glyphicon-pencil"></span></a>
                                    <%--删除--%>
                                <button class="layui-btn layui-btn-danger layui-btn-xs" title="删除"
                                    <%--                                            href="${pageContext.request.contextPath}/product/deleteById?id=${product.id}"--%>
                                        onclick="delids(${users.id},'${users.username}')"><i
                                        class="layui-icon layui-icon-delete"></i> <span
                                        class="glyphicon glyphicon-trash"></span>
                                </button>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <!--分页-->
                <div id="pagesData"></div>

            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>
